<!DOCTYPE html>
<html lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<title>2 A | Glossary</title>
<meta name="author" content="psyTeachR Team">
<meta name="description" content="2.1 absolute path A file path that starts with / and is not appended to the working directory For example, if your working directory is /Users/me/study/ and you want to refer to a file in the...">
<meta name="generator" content="bookdown 0.24 with bs4_book()">
<meta property="og:title" content="2 A | Glossary">
<meta property="og:type" content="book">
<meta property="og:url" content="https://psyteachr.github.io/glossary/a.html">
<meta property="og:image" content="https://psyteachr.github.io/glossary/images/logos/logo.png">
<meta property="og:description" content="2.1 absolute path A file path that starts with / and is not appended to the working directory For example, if your working directory is /Users/me/study/ and you want to refer to a file in the...">
<meta name="twitter:card" content="summary">
<meta name="twitter:title" content="2 A | Glossary">
<meta name="twitter:description" content="2.1 absolute path A file path that starts with / and is not appended to the working directory For example, if your working directory is /Users/me/study/ and you want to refer to a file in the...">
<meta name="twitter:image" content="https://psyteachr.github.io/glossary/images/logos/logo.png">
<!-- JS --><script src="https://cdnjs.cloudflare.com/ajax/libs/clipboard.js/2.0.6/clipboard.min.js" integrity="sha256-inc5kl9MA1hkeYUt+EC3BhlIgyp/2jDIyBLS6k3UxPI=" crossorigin="anonymous"></script><script src="https://cdnjs.cloudflare.com/ajax/libs/fuse.js/6.4.6/fuse.js" integrity="sha512-zv6Ywkjyktsohkbp9bb45V6tEMoWhzFzXis+LrMehmJZZSys19Yxf1dopHx7WzIKxr5tK2dVcYmaCk2uqdjF4A==" crossorigin="anonymous"></script><script src="https://kit.fontawesome.com/6ecbd6c532.js" crossorigin="anonymous"></script><script src="libs/header-attrs-2.11/header-attrs.js"></script><script src="libs/jquery-3.6.0/jquery-3.6.0.min.js"></script><meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<link href="libs/bootstrap-4.6.0/bootstrap.min.css" rel="stylesheet">
<script src="libs/bootstrap-4.6.0/bootstrap.bundle.min.js"></script><script src="libs/bs3compat-0.3.1/transition.js"></script><script src="libs/bs3compat-0.3.1/tabs.js"></script><script src="libs/bs3compat-0.3.1/bs3compat.js"></script><link href="libs/bs4_book-1.0.0/bs4_book.css" rel="stylesheet">
<script src="libs/bs4_book-1.0.0/bs4_book.js"></script><script src="libs/kePrint-0.0.1/kePrint.js"></script><link href="libs/lightable-0.0.1/lightable.css" rel="stylesheet">
<!-- Global site tag (gtag.js) - Google Analytics --><script async src="https://www.googletagmanager.com/gtag/js?id=G-6NP3MF25W3"></script><script>
      window.dataLayer = window.dataLayer || [];
      function gtag(){dataLayer.push(arguments);}
      gtag('js', new Date());

      gtag('config', 'G-6NP3MF25W3');
    </script><script src="https://cdnjs.cloudflare.com/ajax/libs/autocomplete.js/0.38.0/autocomplete.jquery.min.js" integrity="sha512-GU9ayf+66Xx2TmpxqJpliWbT5PiGYxpaG8rfnBEk1LL8l1KGkRShhngwdXK1UgqhAzWpZHSiYPc09/NwDQIGyg==" crossorigin="anonymous"></script><script src="https://cdnjs.cloudflare.com/ajax/libs/mark.js/8.11.1/mark.min.js" integrity="sha512-5CYOlHXGh6QpOFA/TeTylKLWfB3ftPsde7AnmhuitiTX4K5SqCLBeKro6sPS8ilsz1Q4NRx3v8Ko2IBiszzdww==" crossorigin="anonymous"></script><!-- CSS --><link rel="stylesheet" href="include/psyteachr.css">
<link rel="stylesheet" href="include/webex.css">
<link rel="stylesheet" href="include/style.css">
</head>
<body data-spy="scroll" data-target="#toc">

<div class="container-fluid">
<div class="row">
  <header class="col-sm-12 col-lg-3 sidebar sidebar-book"><a class="sr-only sr-only-focusable" href="#content">Skip to main content</a>

    <div class="d-flex align-items-start justify-content-between">
      <h1>
        <a href="index.html" title="">Glossary</a>
      </h1>
      <button class="btn btn-outline-primary d-lg-none ml-2 mt-1" type="button" data-toggle="collapse" data-target="#main-nav" aria-expanded="true" aria-controls="main-nav"><i class="fas fa-bars"></i><span class="sr-only">Show table of contents</span></button>
    </div>

    <div id="main-nav" class="collapse-lg">
      <form role="search">
        <input id="search" class="form-control" type="search" placeholder="Search" aria-label="Search">
</form>

      <nav aria-label="Table of contents"><h2>Table of contents</h2>
        <ul class="book-toc list-unstyled">
<li><a class="" href="index.html">Overview</a></li>
<li><a class="" href="symbols.html"><span class="header-section-number">1</span> Symbols</a></li>
<li><a class="active" href="a.html"><span class="header-section-number">2</span> A</a></li>
<li><a class="" href="b.html"><span class="header-section-number">3</span> B</a></li>
<li><a class="" href="c.html"><span class="header-section-number">4</span> C</a></li>
<li><a class="" href="d.html"><span class="header-section-number">5</span> D</a></li>
<li><a class="" href="e.html"><span class="header-section-number">6</span> E</a></li>
<li><a class="" href="f.html"><span class="header-section-number">7</span> F</a></li>
<li><a class="" href="g.html"><span class="header-section-number">8</span> G</a></li>
<li><a class="" href="h.html"><span class="header-section-number">9</span> H</a></li>
<li><a class="" href="i.html"><span class="header-section-number">10</span> I</a></li>
<li><a class="" href="j.html"><span class="header-section-number">11</span> J</a></li>
<li><a class="" href="k.html"><span class="header-section-number">12</span> K</a></li>
<li><a class="" href="l.html"><span class="header-section-number">13</span> L</a></li>
<li><a class="" href="m.html"><span class="header-section-number">14</span> M</a></li>
<li><a class="" href="n.html"><span class="header-section-number">15</span> N</a></li>
<li><a class="" href="o.html"><span class="header-section-number">16</span> O</a></li>
<li><a class="" href="p.html"><span class="header-section-number">17</span> P</a></li>
<li><a class="" href="q.html"><span class="header-section-number">18</span> Q</a></li>
<li><a class="" href="r.html"><span class="header-section-number">19</span> R</a></li>
<li><a class="" href="s.html"><span class="header-section-number">20</span> S</a></li>
<li><a class="" href="t.html"><span class="header-section-number">21</span> T</a></li>
<li><a class="" href="u.html"><span class="header-section-number">22</span> U</a></li>
<li><a class="" href="v.html"><span class="header-section-number">23</span> V</a></li>
<li><a class="" href="w.html"><span class="header-section-number">24</span> W</a></li>
<li><a class="" href="x.html"><span class="header-section-number">25</span> X</a></li>
<li><a class="" href="y.html"><span class="header-section-number">26</span> Y</a></li>
<li><a class="" href="z.html"><span class="header-section-number">27</span> Z</a></li>
</ul>

        <div class="book-extra">
          <p><a id="book-repo" href="https://github.com/psyteachr/glossary">View book source <i class="fab fa-github"></i></a></p>
        </div>
      </nav>
</div>
  </header><main class="col-sm-12 col-md-9 col-lg-7" id="content"><div id="a" class="section level1" number="2">
<h1>
<span class="header-section-number">2</span> A<a class="anchor" aria-label="anchor" href="#a"><i class="fas fa-link"></i></a>
</h1>

<div id="absolute-path" class="section level2" number="2.1">
<h2>
<span class="header-section-number">2.1</span> absolute path<a class="anchor" aria-label="anchor" href="#absolute-path"><i class="fas fa-link"></i></a>
</h2>
<p><dfn>A file path that starts with / and is not appended to the working directory</dfn></p>
<p>For example, if your <a href="w.html#working-directory">working directory</a> is <code>/Users/me/study/</code> and you want to refer to a file in the directory <code>data</code> called <code>faces.csv</code>, the absolute path is <code>/Users/me/study/data/faces.csv</code>.</p>
<p>However, you should normally use <a href="r.html#relative-path">relative paths</a> in scripts, not absolute paths, which can change when you move a project directory to a new computer or even a new place on your computer.</p>
<p>The package R.utils has a function <code>getAbsolutePath()</code> that returns the absolute path of a file <a href="p.html#path">path</a> or a file <a href="o.html#object">object</a>.</p>
<div class="sourceCode" id="cb10"><pre class="downlit sourceCode r">
<code class="sourceCode R"><span class="fu">R.utils</span><span class="fu">::</span><span class="fu"><a href="https://rdrr.io/pkg/R.utils/man/getAbsolutePath.html">getAbsolutePath</a></span><span class="op">(</span><span class="st">"../index.Rmd"</span><span class="op">)</span>
<span class="co">#&gt; [1] "/Users/lisad/rproj/psyteachr/index.Rmd"</span></code></pre></div>

</div>
<div id="adjusted-r-squared" class="section level2" number="2.2">
<h2>
<span class="header-section-number">2.2</span> adjusted R-squared<a class="anchor" aria-label="anchor" href="#adjusted-r-squared"><i class="fas fa-link"></i></a>
</h2>
<p><dfn>A modified version of <a href="r.html#r-squared">R-squared</a> adjusted for the number of predictors in the model.</dfn></p>

</div>
<div id="alpha" class="section level2" number="2.3">
<h2>
<span class="header-section-number">2.3</span> alpha<a class="anchor" aria-label="anchor" href="#alpha"><i class="fas fa-link"></i></a>
</h2>
<p><dfn>(<a href="a.html#alpha-stats">stats</a>) The cutoff value for making a decision to reject the null hypothesis; (<a href="a.html#alpha-graphics">graphics</a>) A value between 0 and 1 used to control the levels of transparency in a plot</dfn></p>
<p>Can also be a parameter in the <a href="b.html#beta-distribution">beta distribution</a> or refer to <a href="c.html#cronbachs-alpha">Cronbach's alpha</a>.</p>
</div>
<div id="alpha-stats" class="section level2" number="2.4">
<h2>
<span class="header-section-number">2.4</span> alpha (stats)<a class="anchor" aria-label="anchor" href="#alpha-stats"><i class="fas fa-link"></i></a>
</h2>
<p>If you are using null hypothesis significance testing (<a href="n.html#nhst">NHST</a>), then you need to decide on a cutoff value called <strong>alpha</strong> for making a decision to reject the null hypothesis. We call p-values below the alpha cutoff <a href="s.html#significant">significant</a>.</p>
<p>In psychology, alpha is traditionally set at <span class="math inline">\(\alpha\)</span> = .05, but there are good arguments for <a href="http://daniellakens.blogspot.com/2019/05/justifying-your-alpha-by-minimizing-or.html" target="_blank">setting a different criterion in some circumstances</a>.</p>
</div>
<div id="alpha-graphics" class="section level2" number="2.5">
<h2>
<span class="header-section-number">2.5</span> alpha (graphics)<a class="anchor" aria-label="anchor" href="#alpha-graphics"><i class="fas fa-link"></i></a>
</h2>
<p><dfn>A value between 0 and 1 used to control the levels of transparency in a plot</dfn></p>
<div class="sourceCode" id="cb11"><pre class="downlit sourceCode r">
<code class="sourceCode R"><span class="co"># if you omit alpha, it defaults to 1</span>
<span class="va">alpha1.00</span> <span class="op">&lt;-</span> <span class="fu">ggplot</span><span class="op">(</span><span class="va">diamonds</span>, <span class="fu">aes</span><span class="op">(</span>x <span class="op">=</span> <span class="va">depth</span>, fill <span class="op">=</span> <span class="va">cut</span><span class="op">)</span><span class="op">)</span> <span class="op">+</span>
  <span class="fu">geom_density</span><span class="op">(</span><span class="op">)</span> <span class="op">+</span> <span class="fu"><a href="https://rdrr.io/r/graphics/plot.window.html">xlim</a></span><span class="op">(</span><span class="fl">55</span>, <span class="fl">70</span><span class="op">)</span>

<span class="va">alpha0.25</span> <span class="op">&lt;-</span> <span class="fu">ggplot</span><span class="op">(</span><span class="va">diamonds</span>, <span class="fu">aes</span><span class="op">(</span>x <span class="op">=</span> <span class="va">depth</span>, fill <span class="op">=</span> <span class="va">cut</span><span class="op">)</span><span class="op">)</span> <span class="op">+</span>
  <span class="fu">geom_density</span><span class="op">(</span>alpha <span class="op">=</span> <span class="fl">0.25</span><span class="op">)</span> <span class="op">+</span> <span class="fu"><a href="https://rdrr.io/r/graphics/plot.window.html">xlim</a></span><span class="op">(</span><span class="fl">55</span>, <span class="fl">70</span><span class="op">)</span>

<span class="fu">cowplot</span><span class="fu">::</span><span class="fu"><a href="https://wilkelab.org/cowplot/reference/plot_grid.html">plot_grid</a></span><span class="op">(</span><span class="va">alpha1.00</span>, <span class="va">alpha0.25</span>, nrow <span class="op">=</span> <span class="fl">2</span>,
                   labels <span class="op">=</span> <span class="fu"><a href="https://rdrr.io/r/base/c.html">c</a></span><span class="op">(</span><span class="st">"alpha = 1.0"</span>, <span class="st">"alpha = 0.25"</span><span class="op">)</span><span class="op">)</span></code></pre></div>
<div class="figure" style="text-align: center">
<span style="display:block;" id="fig:alpha-plot"></span>
<img src="_main_files/figure-html/alpha-plot-1.png" alt="Setting alpha to a number lower than 1 lets you see parts of the plot hidden behind an object." width="100%"><p class="caption">
Figure 2.1: Setting alpha to a number lower than 1 lets you see parts of the plot hidden behind an object.
</p>
</div>

</div>
<div id="ampersand" class="section level2" number="2.6">
<h2>
<span class="header-section-number">2.6</span> ampersand<a class="anchor" aria-label="anchor" href="#ampersand"><i class="fas fa-link"></i></a>
</h2>
<p><dfn>The <a href="symbols.html">symbol</a> &amp;, an <a href="o.html#operator">operator</a> meaning "AND".</dfn></p>
<p>A single ampersand is <a href="v.html#vectorized">vectorized</a>, so compares each item in the first <a href="v.html#vector">vector</a> with the corresponding item in the second vector.</p>
<div class="sourceCode" id="cb12"><pre class="downlit sourceCode r">
<code class="sourceCode R"><span class="fu"><a href="https://rdrr.io/r/base/c.html">c</a></span><span class="op">(</span><span class="cn">T</span>, <span class="cn">T</span>, <span class="cn">F</span>, <span class="cn">F</span><span class="op">)</span> <span class="op">&amp;</span> <span class="fu"><a href="https://rdrr.io/r/base/c.html">c</a></span><span class="op">(</span><span class="cn">T</span>, <span class="cn">T</span>, <span class="cn">F</span>, <span class="cn">F</span><span class="op">)</span>
<span class="co">#&gt; [1]  TRUE  TRUE FALSE FALSE</span></code></pre></div>
<p>A double ampersand is not vectorised, so will ignore all but the first item in vectors, unless your environment has set <code>_R_CHECK_LENGTH_1_LOGIC2_=true</code>, in which case you will get an error.</p>
<div class="sourceCode" id="cb13"><pre class="downlit sourceCode r">
<code class="sourceCode R"><span class="fu"><a href="https://rdrr.io/r/base/c.html">c</a></span><span class="op">(</span><span class="cn">T</span>, <span class="cn">T</span>, <span class="cn">F</span>, <span class="cn">F</span><span class="op">)</span> <span class="op">&amp;&amp;</span> <span class="fu"><a href="https://rdrr.io/r/base/c.html">c</a></span><span class="op">(</span><span class="cn">T</span>, <span class="cn">T</span>, <span class="cn">F</span>, <span class="cn">F</span><span class="op">)</span>
<span class="co">#&gt; [1] TRUE</span></code></pre></div>
<div class="info">
<p>The advantage of a double ampersand is that it will stop as soon as the conclusion is obvious. So if the first item is FALSE, the second item won't even be run. This is useful for testing whether an object exists before checking something that requires the object to exist.</p>
<div class="sourceCode" id="cb14"><pre class="downlit sourceCode r">
<code class="sourceCode R"><span class="kw">if</span> <span class="op">(</span><span class="fu"><a href="https://rdrr.io/r/base/character.html">is.character</a></span><span class="op">(</span><span class="va">x</span><span class="op">)</span><span class="op">)</span> <span class="op">{</span> 
  <span class="co"># do something</span>
<span class="op">}</span>
<span class="co">#&gt; Error in eval(expr, envir, enclos): object 'x' not found</span></code></pre></div>
<div class="sourceCode" id="cb15"><pre class="downlit sourceCode r">
<code class="sourceCode R"><span class="kw">if</span> <span class="op">(</span><span class="fu"><a href="https://rdrr.io/r/base/exists.html">exists</a></span><span class="op">(</span><span class="st">"x"</span><span class="op">)</span> <span class="op">&amp;&amp;</span> <span class="fu"><a href="https://rdrr.io/r/base/character.html">is.character</a></span><span class="op">(</span><span class="va">x</span><span class="op">)</span><span class="op">)</span> <span class="op">{</span> 
  <span class="co"># do something</span>
<span class="op">}</span></code></pre></div>
</div>

</div>
<div id="anti_join" class="section level2" number="2.7">
<h2>
<span class="header-section-number">2.7</span> anti_join<a class="anchor" aria-label="anchor" href="#anti_join"><i class="fas fa-link"></i></a>
</h2>
<p><dfn>A <a href="f.html#filtering-joins">filtering join</a> that returns all rows from the left table where there are <em>not</em> matching values in the right table, keeping just columns from the left table.</dfn></p>
<div class="figure" style="text-align: center">
<span style="display:block;" id="fig:ani-join"></span>
<img src="images/joins/anti_join.png" alt="Anti Join" width="100%"><p class="caption">
Figure 2.2: Anti Join
</p>
</div>
<p>This is useful when you have a table of data that contains IDs you want to exclude from your main dataset.</p>
<div class="sourceCode" id="cb16"><pre class="downlit sourceCode r">
<code class="sourceCode R"><span class="va">all_data</span> <span class="op">&lt;-</span> <span class="fu"><a href="https://tibble.tidyverse.org/reference/tibble.html">tibble</a></span><span class="op">(</span>
  id <span class="op">=</span> <span class="fl">1</span><span class="op">:</span><span class="fl">5</span>,
  x <span class="op">=</span> <span class="va">LETTERS</span><span class="op">[</span><span class="fl">1</span><span class="op">:</span><span class="fl">5</span><span class="op">]</span>
<span class="op">)</span>

<span class="va">to_exclude</span> <span class="op">&lt;-</span> <span class="fu"><a href="https://tibble.tidyverse.org/reference/tibble.html">tibble</a></span><span class="op">(</span>
  id <span class="op">=</span> <span class="fl">2</span><span class="op">:</span><span class="fl">4</span>
<span class="op">)</span>

<span class="va">data</span> <span class="op">&lt;-</span> <span class="fu"><a href="https://dplyr.tidyverse.org/reference/filter-joins.html">anti_join</a></span><span class="op">(</span><span class="va">all_data</span>, <span class="va">to_exclude</span>, by <span class="op">=</span> <span class="st">"id"</span><span class="op">)</span></code></pre></div>
<div class="inline-table"><table class="table table-sm">
<thead><tr>
<th style="text-align:right;">
id
</th>
<th style="text-align:left;">
x
</th>
</tr></thead>
<tbody>
<tr>
<td style="text-align:right;">
1
</td>
<td style="text-align:left;">
A
</td>
</tr>
<tr>
<td style="text-align:right;">
5
</td>
<td style="text-align:left;">
E
</td>
</tr>
</tbody>
</table></div>
<p>See <a href="j.html#joins">joins</a> for other types of joins and further resources.</p>

</div>
<div id="argument" class="section level2" number="2.8">
<h2>
<span class="header-section-number">2.8</span> argument<a class="anchor" aria-label="anchor" href="#argument"><i class="fas fa-link"></i></a>
</h2>
<p><dfn>A variable that provides input to a <a href="f.html#function">function</a>.</dfn></p>
<p>For example, the first <strong>argument</strong> to the function <code><a href="https://rdrr.io/r/stats/Normal.html">rnorm()</a></code> is <code>n</code> (the number of <a href="o.html#observation">observations</a>).</p>
<p>When you look up the help for a function (e.g., <code><a href="https://rdrr.io/r/stats/sd.html">?sd</a></code>), you will see a section called <strong><code>Arguments</code></strong>, which lists the argument names and their definitions.</p>
<p>The function <code><a href="https://rdrr.io/r/base/args.html">args()</a></code> will show you the argument names and their <a href="d.html#default-value">default values</a> (if any) for any function.</p>
<div class="sourceCode" id="cb17"><pre class="downlit sourceCode r">
<code class="sourceCode R"><span class="fu"><a href="https://rdrr.io/r/base/args.html">args</a></span><span class="op">(</span><span class="va">rnorm</span><span class="op">)</span>
<span class="co">#&gt; function (n, mean = 0, sd = 1) </span>
<span class="co">#&gt; NULL</span></code></pre></div>

</div>
<div id="array" class="section level2" number="2.9">
<h2>
<span class="header-section-number">2.9</span> array<a class="anchor" aria-label="anchor" href="#array"><i class="fas fa-link"></i></a>
</h2>
<p><dfn>A <a href="c.html#container">container</a> that stores <a href="o.html#object">objects</a> in one or more dimensions.</dfn></p>
<p>You can create an array by specifying a list or vector of values and the number of dimensions. The first two dimensions are rows and columns; each dimension after that is printed separately as a facet.</p>
<div class="sourceCode" id="cb18"><pre class="downlit sourceCode r">
<code class="sourceCode R"><span class="co"># 3-dimensional array with 4 rows, 3 columns, and 2 facets</span>
<span class="fu"><a href="https://rdrr.io/r/base/array.html">array</a></span><span class="op">(</span><span class="fl">1</span><span class="op">:</span><span class="fl">24</span>, dim <span class="op">=</span> <span class="fu"><a href="https://rdrr.io/r/base/c.html">c</a></span><span class="op">(</span><span class="fl">4</span>, <span class="fl">3</span>, <span class="fl">2</span><span class="op">)</span><span class="op">)</span>
<span class="co">#&gt; , , 1</span>
<span class="co">#&gt; </span>
<span class="co">#&gt;      [,1] [,2] [,3]</span>
<span class="co">#&gt; [1,]    1    5    9</span>
<span class="co">#&gt; [2,]    2    6   10</span>
<span class="co">#&gt; [3,]    3    7   11</span>
<span class="co">#&gt; [4,]    4    8   12</span>
<span class="co">#&gt; </span>
<span class="co">#&gt; , , 2</span>
<span class="co">#&gt; </span>
<span class="co">#&gt;      [,1] [,2] [,3]</span>
<span class="co">#&gt; [1,]   13   17   21</span>
<span class="co">#&gt; [2,]   14   18   22</span>
<span class="co">#&gt; [3,]   15   19   23</span>
<span class="co">#&gt; [4,]   16   20   24</span></code></pre></div>
<p>You can give your array dimensions names.</p>
<div class="sourceCode" id="cb19"><pre class="downlit sourceCode r">
<code class="sourceCode R">
<span class="va">dimnames</span> <span class="op">&lt;-</span> <span class="fu"><a href="https://rdrr.io/r/base/list.html">list</a></span><span class="op">(</span>
  subj_id <span class="op">=</span> <span class="fu"><a href="https://rdrr.io/r/base/c.html">c</a></span><span class="op">(</span><span class="st">"S1"</span>, <span class="st">"S2"</span>, <span class="st">"S3"</span>, <span class="st">"S4"</span><span class="op">)</span>,
  face_id <span class="op">=</span> <span class="fu"><a href="https://rdrr.io/r/base/c.html">c</a></span><span class="op">(</span><span class="st">"F1"</span>, <span class="st">"F2"</span>, <span class="st">"F3"</span><span class="op">)</span>,
  condition <span class="op">=</span> <span class="fu"><a href="https://rdrr.io/r/base/c.html">c</a></span><span class="op">(</span><span class="st">"Control"</span>, <span class="st">"experimental"</span><span class="op">)</span>
<span class="op">)</span>
  
<span class="fu"><a href="https://rdrr.io/r/base/array.html">array</a></span><span class="op">(</span><span class="fl">1</span><span class="op">:</span><span class="fl">24</span>, dim <span class="op">=</span> <span class="fu"><a href="https://rdrr.io/r/base/c.html">c</a></span><span class="op">(</span><span class="fl">4</span>, <span class="fl">3</span>, <span class="fl">2</span><span class="op">)</span>, dimnames <span class="op">=</span> <span class="va">dimnames</span><span class="op">)</span>
<span class="co">#&gt; , , condition = Control</span>
<span class="co">#&gt; </span>
<span class="co">#&gt;        face_id</span>
<span class="co">#&gt; subj_id F1 F2 F3</span>
<span class="co">#&gt;      S1  1  5  9</span>
<span class="co">#&gt;      S2  2  6 10</span>
<span class="co">#&gt;      S3  3  7 11</span>
<span class="co">#&gt;      S4  4  8 12</span>
<span class="co">#&gt; </span>
<span class="co">#&gt; , , condition = experimental</span>
<span class="co">#&gt; </span>
<span class="co">#&gt;        face_id</span>
<span class="co">#&gt; subj_id F1 F2 F3</span>
<span class="co">#&gt;      S1 13 17 21</span>
<span class="co">#&gt;      S2 14 18 22</span>
<span class="co">#&gt;      S3 15 19 23</span>
<span class="co">#&gt;      S4 16 20 24</span></code></pre></div>
<p>Objects not need to be the same <a href="d.html#data-type">data type</a>.</p>
<div class="sourceCode" id="cb20"><pre class="downlit sourceCode r">
<code class="sourceCode R"><span class="va">mylist</span> <span class="op">&lt;-</span> <span class="fu"><a href="https://rdrr.io/r/base/list.html">list</a></span><span class="op">(</span><span class="st">"A"</span>, <span class="cn">TRUE</span>, <span class="fl">2L</span>, <span class="fl">3.1</span><span class="op">)</span>
<span class="va">myarray</span> <span class="op">&lt;-</span> <span class="fu"><a href="https://rdrr.io/r/base/array.html">array</a></span><span class="op">(</span><span class="va">mylist</span>, dim <span class="op">=</span> <span class="fu"><a href="https://rdrr.io/r/base/c.html">c</a></span><span class="op">(</span><span class="fl">2</span>,<span class="fl">2</span><span class="op">)</span><span class="op">)</span>

<span class="fu"><a href="https://rdrr.io/r/base/c.html">c</a></span><span class="op">(</span>
  <span class="va">myarray</span><span class="op">[[</span><span class="fl">1</span>,<span class="fl">1</span><span class="op">]</span><span class="op">]</span> <span class="op">%&gt;%</span> <span class="fu"><a href="https://rdrr.io/r/base/class.html">class</a></span><span class="op">(</span><span class="op">)</span>,
  <span class="va">myarray</span><span class="op">[[</span><span class="fl">1</span>,<span class="fl">2</span><span class="op">]</span><span class="op">]</span> <span class="op">%&gt;%</span> <span class="fu"><a href="https://rdrr.io/r/base/class.html">class</a></span><span class="op">(</span><span class="op">)</span>,
  <span class="va">myarray</span><span class="op">[[</span><span class="fl">2</span>,<span class="fl">1</span><span class="op">]</span><span class="op">]</span> <span class="op">%&gt;%</span> <span class="fu"><a href="https://rdrr.io/r/base/class.html">class</a></span><span class="op">(</span><span class="op">)</span>,
  <span class="va">myarray</span><span class="op">[[</span><span class="fl">2</span>,<span class="fl">2</span><span class="op">]</span><span class="op">]</span> <span class="op">%&gt;%</span> <span class="fu"><a href="https://rdrr.io/r/base/class.html">class</a></span><span class="op">(</span><span class="op">)</span>
<span class="op">)</span>
<span class="co">#&gt; [1] "character" "integer"   "logical"   "numeric"</span></code></pre></div>

</div>
<div id="aspect-ratio" class="section level2" number="2.10">
<h2>
<span class="header-section-number">2.10</span> aspect ratio<a class="anchor" aria-label="anchor" href="#aspect-ratio"><i class="fas fa-link"></i></a>
</h2>
<p><dfn>The ratio between the width and height of an image.</dfn></p>
<p>You can specify the aspect ratio of your plots by setting the width and height in the first chunk of an R Markdown file like this:</p>
<div class="sourceCode" id="cb21"><pre class="downlit sourceCode r">
<code class="sourceCode R"><span class="fu">knitr</span><span class="fu">::</span><span class="va"><a href="https://rdrr.io/pkg/knitr/man/opts_chunk.html">opts_chunk</a></span><span class="op">$</span><span class="fu">set</span><span class="op">(</span>
  fig.width <span class="op">=</span> <span class="fl">7</span>, <span class="co"># default value is 7</span>
  fig.height <span class="op">=</span> <span class="fl">7</span><span class="op">/</span><span class="fl">1.618</span> <span class="co"># rolden ratio; default value is 7</span>
<span class="op">)</span></code></pre></div>
<p>Or in the <a href="c.html#chunk">chunk</a> options:</p>
<div class="verbatim">
<p><code>```{r fig-golden-ratio, fig.width = 7, fig.height = 4.32}</code></p>
<div class="sourceCode" id="cb22"><pre class="downlit sourceCode r">
<code class="sourceCode R"><span class="fu">ggplot</span><span class="op">(</span><span class="va">iris</span>, <span class="fu">aes</span><span class="op">(</span><span class="va">Sepal.Width</span>, <span class="va">Sepal.Length</span>, color <span class="op">=</span> <span class="va">Species</span><span class="op">)</span><span class="op">)</span> <span class="op">+</span>
  <span class="fu">geom_point</span><span class="op">(</span><span class="op">)</span> <span class="op">+</span>
  <span class="fu">geom_smooth</span><span class="op">(</span>method <span class="op">=</span> <span class="va">lm</span>, formula <span class="op">=</span> <span class="va">y</span><span class="op">~</span><span class="va">x</span><span class="op">)</span></code></pre></div>
<code>```</code>
</div>
<div class="figure" style="text-align: center">
<span style="display:block;" id="fig:aspect-ratio-1-displ"></span>
<img src="_main_files/figure-html/aspect-ratio-1-displ-1.png" alt="Plot with a 1.618:1 aspect ratio (golden ratio)" width="100%"><p class="caption">
Figure 2.3: Plot with a 1.618:1 aspect ratio (golden ratio)
</p>
</div>
<div class="verbatim">
<p><code>```{r fig-square, fig.width = 7, fig.height = 7}</code></p>
<div class="sourceCode" id="cb23"><pre class="downlit sourceCode r">
<code class="sourceCode R"><span class="fu">ggplot</span><span class="op">(</span><span class="va">iris</span>, <span class="fu">aes</span><span class="op">(</span><span class="va">Sepal.Width</span>, <span class="va">Sepal.Length</span>, color <span class="op">=</span> <span class="va">Species</span><span class="op">)</span><span class="op">)</span> <span class="op">+</span>
  <span class="fu">geom_point</span><span class="op">(</span><span class="op">)</span> <span class="op">+</span>
  <span class="fu">geom_smooth</span><span class="op">(</span>method <span class="op">=</span> <span class="va">lm</span>, formula <span class="op">=</span> <span class="va">y</span><span class="op">~</span><span class="va">x</span><span class="op">)</span></code></pre></div>
<code>```</code>
</div>
<div class="figure" style="text-align: center">
<span style="display:block;" id="fig:aspect-ratio-2-disp"></span>
<img src="_main_files/figure-html/aspect-ratio-2-disp-1.png" alt="Plot with a 1:1 aspect ratio" width="100%"><p class="caption">
Figure 2.4: Plot with a 1:1 aspect ratio
</p>
</div>
<p>Or when you save the image:</p>
<div class="sourceCode" id="cb24"><pre class="downlit sourceCode r">
<code class="sourceCode R"><span class="fu">ggsave</span><span class="op">(</span><span class="st">"golden-ratio.jpg"</span>, width <span class="op">=</span> <span class="fl">7</span>, height <span class="op">=</span> <span class="fl">7</span><span class="op">/</span><span class="fl">1.618</span><span class="op">)</span></code></pre></div>

</div>
<div id="assignment-operator" class="section level2" number="2.11">
<h2>
<span class="header-section-number">2.11</span> assignment operator<a class="anchor" aria-label="anchor" href="#assignment-operator"><i class="fas fa-link"></i></a>
</h2>
<p><dfn>The <a href="symbols.html">symbol</a> <code><a href="https://rdrr.io/r/base/assignOps.html">&lt;-</a></code>, which functions like <code><a href="https://rdrr.io/r/base/assignOps.html">=</a></code> and assigns the value on the right to the object on the left</dfn></p>
<div class="sourceCode" id="cb25"><pre class="downlit sourceCode r">
<code class="sourceCode R"><span class="va">a</span> <span class="op">&lt;-</span> <span class="fl">1</span>

<span class="va">a</span>
<span class="co">#&gt; [1] 1</span></code></pre></div>
<p>The assignment operator can also be reversed</p>
<div class="sourceCode" id="cb26"><pre class="downlit sourceCode r">
<code class="sourceCode R"><span class="fl">2</span> <span class="op">-&gt;</span> <span class="va">b</span>

<span class="va">b</span>
<span class="co">#&gt; [1] 2</span></code></pre></div>
<p>And even go in both direction at the same time!</p>
<div class="sourceCode" id="cb27"><pre class="downlit sourceCode r">
<code class="sourceCode R"><span class="va">x</span> <span class="op">&lt;-</span> <span class="fl">2</span> <span class="op">-&gt;</span> <span class="va">y</span>

<span class="va">x</span>
<span class="co">#&gt; [1] 2</span>
<span class="va">y</span>
<span class="co">#&gt; [1] 2</span></code></pre></div>

</div>
<div id="atomic" class="section level2" number="2.12">
<h2>
<span class="header-section-number">2.12</span> atomic<a class="anchor" aria-label="anchor" href="#atomic"><i class="fas fa-link"></i></a>
</h2>
<p><dfn>Only containing <a href="o.html#object">objects</a> with the same <a href="d.html#data-type">data type</a> (e.g., all <a href="n.html#numeric">numeric</a> or <a href="c.html#character">character</a>).</dfn></p>
<p><a href="v.html#vector">Vectors</a> are atomic data structures in R.</p>
<div class="sourceCode" id="cb28"><pre class="downlit sourceCode r">
<code class="sourceCode R"><span class="va">a</span> <span class="op">&lt;-</span> <span class="fu"><a href="https://rdrr.io/r/base/c.html">c</a></span><span class="op">(</span><span class="fl">1</span>, <span class="fl">4</span>, <span class="fl">32</span><span class="op">)</span>
<span class="va">b</span> <span class="op">&lt;-</span> <span class="fu"><a href="https://rdrr.io/r/base/c.html">c</a></span><span class="op">(</span><span class="st">"somebody"</span>, <span class="st">"once"</span>, <span class="st">"told me"</span><span class="op">)</span>
<span class="fu"><a href="https://rdrr.io/r/base/class.html">class</a></span><span class="op">(</span><span class="va">a</span><span class="op">)</span>
<span class="co">#&gt; [1] "numeric"</span>
<span class="fu"><a href="https://rdrr.io/r/base/class.html">class</a></span><span class="op">(</span><span class="va">b</span><span class="op">)</span>
<span class="co">#&gt; [1] "character"</span></code></pre></div>
<p>If you try to mix data types in an atomic vector, they will be <a href="c.html#coerce">coerced</a> to be the same type. (Note that 32 becomes "32" so it can be in the same vector as a character object).</p>
<div class="sourceCode" id="cb29"><pre class="downlit sourceCode r">
<code class="sourceCode R"><span class="fu"><a href="https://rdrr.io/r/base/c.html">c</a></span><span class="op">(</span><span class="fl">32</span>, <span class="cn">TRUE</span>, <span class="st">"eighteen"</span><span class="op">)</span>
<span class="co">#&gt; [1] "32"       "TRUE"     "eighteen"</span></code></pre></div>
<p>Another feature of vectors that makes them atomic is that they are always flat. If you embed vectors within vectors, they will be flattened.</p>
<div class="sourceCode" id="cb30"><pre class="downlit sourceCode r">
<code class="sourceCode R"><span class="fu"><a href="https://rdrr.io/r/base/c.html">c</a></span><span class="op">(</span><span class="fl">7</span>, <span class="fu"><a href="https://rdrr.io/r/base/c.html">c</a></span><span class="op">(</span><span class="fl">1</span>, <span class="fl">4</span>, <span class="fl">32</span><span class="op">)</span>, <span class="fl">2</span>, <span class="fl">6</span><span class="op">)</span>
<span class="co">#&gt; [1]  7  1  4 32  2  6</span></code></pre></div>
<p><a href="l.html#list">Lists</a>, on the other hand, can be nested.</p>
<div class="sourceCode" id="cb31"><pre class="downlit sourceCode r">
<code class="sourceCode R"><span class="fu"><a href="https://rdrr.io/r/base/list.html">list</a></span><span class="op">(</span><span class="fl">7</span>, <span class="fu"><a href="https://rdrr.io/r/base/c.html">c</a></span><span class="op">(</span><span class="fl">1</span>, <span class="fl">4</span>, <span class="fl">32</span><span class="op">)</span>, <span class="fl">2</span>, <span class="fl">6</span><span class="op">)</span> <span class="op">%&gt;%</span> <span class="fu"><a href="https://rdrr.io/r/utils/str.html">str</a></span><span class="op">(</span><span class="op">)</span>
<span class="co">#&gt; List of 4</span>
<span class="co">#&gt;  $ : num 7</span>
<span class="co">#&gt;  $ : num [1:3] 1 4 32</span>
<span class="co">#&gt;  $ : num 2</span>
<span class="co">#&gt;  $ : num 6</span></code></pre></div>
<p>If you try to extract objects inside an atomic vector, you need to use <a href="b.html#brackets">brackets</a> <code>[]</code>. This can be with an index or a name. Single brackets can return one or more elements, and include names, while double brackets can only return one element and don't have names.</p>
<div class="sourceCode" id="cb32"><pre class="downlit sourceCode r">
<code class="sourceCode R"><span class="va">my_vec</span> <span class="op">&lt;-</span> <span class="fu"><a href="https://rdrr.io/r/base/c.html">c</a></span><span class="op">(</span>x <span class="op">=</span> <span class="fl">3</span>, y <span class="op">=</span> <span class="fl">1</span>, z <span class="op">=</span> <span class="fl">4</span><span class="op">)</span>
<span class="va">my_vec</span><span class="op">[</span><span class="fl">2</span><span class="op">]</span>
<span class="co">#&gt; y </span>
<span class="co">#&gt; 1</span>
<span class="va">my_vec</span><span class="op">[</span><span class="st">"y"</span><span class="op">]</span>
<span class="co">#&gt; y </span>
<span class="co">#&gt; 1</span>
<span class="va">my_vec</span><span class="op">[[</span><span class="st">"y"</span><span class="op">]</span><span class="op">]</span>
<span class="co">#&gt; [1] 1</span></code></pre></div>
<p>You cannot use the $ operator on an atomic vector, or you will get this very common error.</p>
<div class="sourceCode" id="cb33"><pre class="downlit sourceCode r">
<code class="sourceCode R"><span class="va">my_vec</span><span class="op">$</span><span class="va">y</span>
<span class="co">#&gt; Error in my_vec$y: $ operator is invalid for atomic vectors</span></code></pre></div>
<p>See the <a href="https://adv-r.hadley.nz/vectors-chap.html#atomic-vectors">Vectors chapter</a> of Advanced R for more advanced discussion of atomic vectors.</p>

</div>
<div id="attribute" class="section level2" number="2.13">
<h2>
<span class="header-section-number">2.13</span> attribute<a class="anchor" aria-label="anchor" href="#attribute"><i class="fas fa-link"></i></a>
</h2>
<p><dfn>Extra information about an R object</dfn></p>
<p>You can access an <a href="o.html#object">object</a>'s attributes with <code><a href="https://rdrr.io/r/base/attr.html">attr()</a></code>. For example, datasets simulated with <a href="https://debruine.github.io/faux/" target="_blank">faux</a> have an attribute called "design" that details their design.</p>
<div class="sourceCode" id="cb34"><pre class="downlit sourceCode r">
<code class="sourceCode R"><span class="va">data</span> <span class="op">&lt;-</span> <span class="fu">faux</span><span class="fu">::</span><span class="fu"><a href="https://rdrr.io/pkg/faux/man/sim_design.html">sim_design</a></span><span class="op">(</span>
  between <span class="op">=</span> <span class="fu"><a href="https://rdrr.io/r/base/list.html">list</a></span><span class="op">(</span>pet <span class="op">=</span> <span class="fu"><a href="https://rdrr.io/r/base/c.html">c</a></span><span class="op">(</span>cat <span class="op">=</span> <span class="st">"Cat Owners"</span>, 
                         dog <span class="op">=</span> <span class="st">"Dog Owners"</span><span class="op">)</span><span class="op">)</span>,
  within <span class="op">=</span> <span class="fu"><a href="https://rdrr.io/r/base/list.html">list</a></span><span class="op">(</span>time <span class="op">=</span> <span class="fu"><a href="https://rdrr.io/r/base/c.html">c</a></span><span class="op">(</span>am <span class="op">=</span> <span class="st">"Morning"</span>, 
                         pm <span class="op">=</span> <span class="st">"Night"</span><span class="op">)</span><span class="op">)</span>,
  mu <span class="op">=</span> <span class="fl">1</span><span class="op">:</span><span class="fl">4</span>,
  r <span class="op">=</span> <span class="fu"><a href="https://rdrr.io/r/base/list.html">list</a></span><span class="op">(</span>cat <span class="op">=</span> <span class="fl">0.3</span>, dog <span class="op">=</span> <span class="fl">0.6</span><span class="op">)</span>,
  dv <span class="op">=</span> <span class="fu"><a href="https://rdrr.io/r/base/c.html">c</a></span><span class="op">(</span>score <span class="op">=</span> <span class="st">"Happiness Scale Score"</span><span class="op">)</span>,
  plot <span class="op">=</span> <span class="cn">FALSE</span><span class="op">)</span>

<span class="fu"><a href="https://rdrr.io/r/base/attr.html">attr</a></span><span class="op">(</span><span class="va">data</span>, <span class="st">"design"</span><span class="op">)</span>
<span class="co">#&gt; * [DV] score: Happiness Scale Score  </span>
<span class="co">#&gt; * [ID] id: id  </span>
<span class="co">#&gt; * Within-subject variables:</span>
<span class="co">#&gt;     * time: </span>
<span class="co">#&gt;         * am: Morning</span>
<span class="co">#&gt;         * pm: Night</span>
<span class="co">#&gt; * Between-subject variables:</span>
<span class="co">#&gt;     * pet: </span>
<span class="co">#&gt;         * cat: Cat Owners</span>
<span class="co">#&gt;         * dog: Dog Owners</span>
<span class="co">#&gt; * Parameters:</span>
<span class="co">#&gt;     &lt;table&gt;</span>
<span class="co">#&gt;  &lt;thead&gt;</span>
<span class="co">#&gt;   &lt;tr&gt;</span>
<span class="co">#&gt;    &lt;th style="text-align:left;"&gt; pet &lt;/th&gt;</span>
<span class="co">#&gt;    &lt;th style="text-align:left;"&gt; time &lt;/th&gt;</span>
<span class="co">#&gt;    &lt;th style="text-align:right;"&gt; am &lt;/th&gt;</span>
<span class="co">#&gt;    &lt;th style="text-align:right;"&gt; pm &lt;/th&gt;</span>
<span class="co">#&gt;    &lt;th style="text-align:right;"&gt; n &lt;/th&gt;</span>
<span class="co">#&gt;    &lt;th style="text-align:right;"&gt; mu &lt;/th&gt;</span>
<span class="co">#&gt;    &lt;th style="text-align:right;"&gt; sd &lt;/th&gt;</span>
<span class="co">#&gt;   &lt;/tr&gt;</span>
<span class="co">#&gt;  &lt;/thead&gt;</span>
<span class="co">#&gt; &lt;tbody&gt;</span>
<span class="co">#&gt;   &lt;tr&gt;</span>
<span class="co">#&gt;    &lt;td style="text-align:left;"&gt; cat &lt;/td&gt;</span>
<span class="co">#&gt;    &lt;td style="text-align:left;"&gt; am &lt;/td&gt;</span>
<span class="co">#&gt;    &lt;td style="text-align:right;"&gt; 1.0 &lt;/td&gt;</span>
<span class="co">#&gt;    &lt;td style="text-align:right;"&gt; 0.3 &lt;/td&gt;</span>
<span class="co">#&gt;    &lt;td style="text-align:right;"&gt; 100 &lt;/td&gt;</span>
<span class="co">#&gt;    &lt;td style="text-align:right;"&gt; 1 &lt;/td&gt;</span>
<span class="co">#&gt;    &lt;td style="text-align:right;"&gt; 1 &lt;/td&gt;</span>
<span class="co">#&gt;   &lt;/tr&gt;</span>
<span class="co">#&gt;   &lt;tr&gt;</span>
<span class="co">#&gt;    &lt;td style="text-align:left;"&gt; cat &lt;/td&gt;</span>
<span class="co">#&gt;    &lt;td style="text-align:left;"&gt; pm &lt;/td&gt;</span>
<span class="co">#&gt;    &lt;td style="text-align:right;"&gt; 0.3 &lt;/td&gt;</span>
<span class="co">#&gt;    &lt;td style="text-align:right;"&gt; 1.0 &lt;/td&gt;</span>
<span class="co">#&gt;    &lt;td style="text-align:right;"&gt; 100 &lt;/td&gt;</span>
<span class="co">#&gt;    &lt;td style="text-align:right;"&gt; 2 &lt;/td&gt;</span>
<span class="co">#&gt;    &lt;td style="text-align:right;"&gt; 1 &lt;/td&gt;</span>
<span class="co">#&gt;   &lt;/tr&gt;</span>
<span class="co">#&gt;   &lt;tr&gt;</span>
<span class="co">#&gt;    &lt;td style="text-align:left;"&gt; dog &lt;/td&gt;</span>
<span class="co">#&gt;    &lt;td style="text-align:left;"&gt; am &lt;/td&gt;</span>
<span class="co">#&gt;    &lt;td style="text-align:right;"&gt; 1.0 &lt;/td&gt;</span>
<span class="co">#&gt;    &lt;td style="text-align:right;"&gt; 0.6 &lt;/td&gt;</span>
<span class="co">#&gt;    &lt;td style="text-align:right;"&gt; 100 &lt;/td&gt;</span>
<span class="co">#&gt;    &lt;td style="text-align:right;"&gt; 3 &lt;/td&gt;</span>
<span class="co">#&gt;    &lt;td style="text-align:right;"&gt; 1 &lt;/td&gt;</span>
<span class="co">#&gt;   &lt;/tr&gt;</span>
<span class="co">#&gt;   &lt;tr&gt;</span>
<span class="co">#&gt;    &lt;td style="text-align:left;"&gt; dog &lt;/td&gt;</span>
<span class="co">#&gt;    &lt;td style="text-align:left;"&gt; pm &lt;/td&gt;</span>
<span class="co">#&gt;    &lt;td style="text-align:right;"&gt; 0.6 &lt;/td&gt;</span>
<span class="co">#&gt;    &lt;td style="text-align:right;"&gt; 1.0 &lt;/td&gt;</span>
<span class="co">#&gt;    &lt;td style="text-align:right;"&gt; 100 &lt;/td&gt;</span>
<span class="co">#&gt;    &lt;td style="text-align:right;"&gt; 4 &lt;/td&gt;</span>
<span class="co">#&gt;    &lt;td style="text-align:right;"&gt; 1 &lt;/td&gt;</span>
<span class="co">#&gt;   &lt;/tr&gt;</span>
<span class="co">#&gt; &lt;/tbody&gt;</span>
<span class="co">#&gt; &lt;/table&gt;</span></code></pre></div>
</div>
<div id="attribute-html" class="section level2" number="2.14">
<h2>
<span class="header-section-number">2.14</span> attribute (html)<a class="anchor" aria-label="anchor" href="#attribute-html"><i class="fas fa-link"></i></a>
</h2>
<p><dfn>Extra information about an HTML element</dfn></p>
<p>For example, the paragraph <a href="e.html#element-html">element</a> has an attribute of "id" with a value of "feature". This can be used to refer to the element to change its style with <a href="c.html#css">CSS</a> or affect its behaviour with <a href="j.html#javascript">JavaScript</a>.</p>
<div class="sourceCode" id="cb35"><pre class="sourceCode html"><code class="sourceCode html"><span id="cb35-1"><a href="a.html#cb35-1" aria-hidden="true" tabindex="-1"></a><span class="kw">&lt;p</span> <span class="er">id</span><span class="ot">=</span><span class="st">"feature"</span><span class="kw">&gt;</span>This is the main paragraoh of my text...<span class="kw">&lt;/p&gt;</span></span></code></pre></div>

</div>
</div>
<script>

/* update total correct if #webex-total_correct exists */
update_total_correct = function() {
  console.log("webex: update total_correct");

  if (t = document.getElementById("webex-total_correct")) {
    var correct = document.getElementsByClassName("webex-correct").length;
    var solvemes = document.getElementsByClassName("webex-solveme").length;
    var radiogroups = document.getElementsByClassName("webex-radiogroup").length;
    var selects = document.getElementsByClassName("webex-select").length;
    
    t.innerHTML = correct + " of " + (solvemes + radiogroups + selects) + " correct";
  }
}

/* webex-solution button toggling function */
b_func = function() {
  console.log("webex: toggle hide");
  
  var cl = this.parentElement.classList;
  if (cl.contains('open')) {
    cl.remove("open");
  } else {
    cl.add("open");
  }
}

/* function for checking solveme answers */
solveme_func = function(e) {
  console.log("webex: check solveme");

  var real_answers = JSON.parse(this.dataset.answer);
  var my_answer = this.value;
  var cl = this.classList;
  if (cl.contains("ignorecase")) {
    my_answer = my_answer.toLowerCase();
  }
  if (cl.contains("nospaces")) {
    my_answer = my_answer.replace(/ /g, "")
  }

  if (my_answer == "") {
    cl.remove("webex-correct");
    cl.remove("webex-incorrect");
  } else if (real_answers.includes(my_answer)) {
    cl.add("webex-correct");
    cl.remove("webex-incorrect");
  } else {
    cl.add("webex-incorrect");
    cl.remove("webex-correct");
  }

  // match numeric answers within a specified tolerance
  if(this.dataset.tol > 0){
    var tol = JSON.parse(this.dataset.tol);
    var matches = real_answers.map(x => Math.abs(x - my_answer) < tol)
    if (matches.reduce((a, b) => a + b, 0) > 0) {
      cl.add("webex-correct");
    } else {
      cl.remove("webex-correct");
    }
  }

  // added regex bit
  if (cl.contains("regex")){
    answer_regex = RegExp(real_answers.join("|"))
    if (answer_regex.test(my_answer)) {
      cl.add("webex-correct");
    }
  }

  update_total_correct();
}

/* function for checking select answers */
select_func = function(e) {
  console.log("webex: check select");
  
  var cl = this.classList
  
  /* add style */
  cl.remove("webex-incorrect");
  cl.remove("webex-correct");
  if (this.value == "answer") {
    cl.add("webex-correct");
  } else if (this.value != "blank") {
    cl.add("webex-incorrect");
  }
  
  update_total_correct();
}

/* function for checking radiogroups answers */
radiogroups_func = function(e) {
  console.log("webex: check radiogroups");

  var checked_button = document.querySelector('input[name=' + this.id + ']:checked');
  var cl = checked_button.parentElement.classList;
  var labels = checked_button.parentElement.parentElement.children;
  
  /* get rid of styles */
  for (i = 0; i < labels.length; i++) {
    labels[i].classList.remove("webex-incorrect");
    labels[i].classList.remove("webex-correct");
  }
  
  /* add style */
  if (checked_button.value == "answer") {
    cl.add("webex-correct");
  } else {
    cl.add("webex-incorrect");
  }
  
  update_total_correct();
}

window.onload = function() {
  console.log("onload");
  /* set up solution buttons */
  var buttons = document.getElementsByTagName("button");

  for (var i = 0; i < buttons.length; i++) {
    if (buttons[i].parentElement.classList.contains('webex-solution')) {
      buttons[i].onclick = b_func;
    }
  }

  /* set up webex-solveme inputs */
  var solveme = document.getElementsByClassName("webex-solveme");

  for (var i = 0; i < solveme.length; i++) {
    /* make sure input boxes don't auto-anything */
    solveme[i].setAttribute("autocomplete","off");
    solveme[i].setAttribute("autocorrect", "off");
    solveme[i].setAttribute("autocapitalize", "off");
    solveme[i].setAttribute("spellcheck", "false");
    solveme[i].value = "";

    /* adjust answer for ignorecase or nospaces */
    var cl = solveme[i].classList;
    var real_answer = solveme[i].dataset.answer;
    if (cl.contains("ignorecase")) {
      real_answer = real_answer.toLowerCase();
    }
    if (cl.contains("nospaces")) {
      real_answer = real_answer.replace(/ /g, "");
    }
    solveme[i].dataset.answer = real_answer;

    /* attach checking function */
    solveme[i].onkeyup = solveme_func;
    solveme[i].onchange = solveme_func;
  }
  
  /* set up radiogroups */
  var radiogroups = document.getElementsByClassName("webex-radiogroup");
  for (var i = 0; i < radiogroups.length; i++) {
    radiogroups[i].onchange = radiogroups_func;
  }
  
  /* set up selects */
  var selects = document.getElementsByClassName("webex-select");
  for (var i = 0; i < selects.length; i++) {
    selects[i].onchange = select_func;
  }

  update_total_correct();
}

</script><script>
$( document ).ready(function() {
  var cite = ' ';
  var psyteachr = ' <a href="https://psyteachr.github.io/"><img src="images/logos/psyteachr_logo.png" style="height: 31px; color: white;" alt="psyTeachR: Reproducible Research" /></a>';
  var license = ' <a rel="license" href="https://creativecommons.org/licenses/by-sa/4.0/" target="blank"><img alt="Creative Commons License" style="border-width:0" src="https://i.creativecommons.org/l/by-sa/4.0/88x31.png"></a>';

  $("footer div.row div:eq(1) p").html(
    psyteachr + license + cite
  );
  
  $("#toc").appendTo($("#main-nav"));
});
</script><div class="chapter-nav">
<div class="prev"><a href="symbols.html"><span class="header-section-number">1</span> Symbols</a></div>
<div class="next"><a href="b.html"><span class="header-section-number">3</span> B</a></div>
</div></main><div class="col-md-3 col-lg-2 d-none d-md-block sidebar sidebar-chapter">
    <nav id="toc" data-toggle="toc" aria-label="On this page"><h2>On this page</h2>
      <ul class="nav navbar-nav">
<li><a class="nav-link" href="#a"><span class="header-section-number">2</span> A</a></li>
<li><a class="nav-link" href="#absolute-path"><span class="header-section-number">2.1</span> absolute path</a></li>
<li><a class="nav-link" href="#adjusted-r-squared"><span class="header-section-number">2.2</span> adjusted R-squared</a></li>
<li><a class="nav-link" href="#alpha"><span class="header-section-number">2.3</span> alpha</a></li>
<li><a class="nav-link" href="#alpha-stats"><span class="header-section-number">2.4</span> alpha (stats)</a></li>
<li><a class="nav-link" href="#alpha-graphics"><span class="header-section-number">2.5</span> alpha (graphics)</a></li>
<li><a class="nav-link" href="#ampersand"><span class="header-section-number">2.6</span> ampersand</a></li>
<li><a class="nav-link" href="#anti_join"><span class="header-section-number">2.7</span> anti_join</a></li>
<li><a class="nav-link" href="#argument"><span class="header-section-number">2.8</span> argument</a></li>
<li><a class="nav-link" href="#array"><span class="header-section-number">2.9</span> array</a></li>
<li><a class="nav-link" href="#aspect-ratio"><span class="header-section-number">2.10</span> aspect ratio</a></li>
<li><a class="nav-link" href="#assignment-operator"><span class="header-section-number">2.11</span> assignment operator</a></li>
<li><a class="nav-link" href="#atomic"><span class="header-section-number">2.12</span> atomic</a></li>
<li><a class="nav-link" href="#attribute"><span class="header-section-number">2.13</span> attribute</a></li>
<li><a class="nav-link" href="#attribute-html"><span class="header-section-number">2.14</span> attribute (html)</a></li>
</ul>

      <div class="book-extra">
        <ul class="list-unstyled">
<li><a id="book-source" href="https://github.com/psyteachr/glossary/blob/master/terms/a.Rmd">View source <i class="fab fa-github"></i></a></li>
          <li><a id="book-edit" href="https://github.com/psyteachr/glossary/edit/master/terms/a.Rmd">Edit this page <i class="fab fa-github"></i></a></li>
        </ul>
</div>
    </nav>
</div>

</div>
</div> <!-- .container -->

<footer class="bg-primary text-light mt-5"><div class="container"><div class="row">

  <div class="col-12 col-md-6 mt-3">
    <p>"<strong>Glossary</strong>" was written by psyTeachR Team. It was last built on 2022-02-10.</p>
  </div>

  <div class="col-12 col-md-6 mt-3">
    <p>This book was built by the <a class="text-light" href="https://bookdown.org">bookdown</a> R package.</p>
  </div>

</div></div>
</footer><!-- dynamically load mathjax for compatibility with self-contained --><script>
  (function () {
    var script = document.createElement("script");
    script.type = "text/javascript";
    var src = "true";
    if (src === "" || src === "true") src = "https://mathjax.rstudio.com/latest/MathJax.js?config=TeX-MML-AM_CHTML";
    if (location.protocol !== "file:")
      if (/^https?:/.test(src))
        src = src.replace(/^https?:/, '');
    script.src = src;
    document.getElementsByTagName("head")[0].appendChild(script);
  })();
</script><script type="text/x-mathjax-config">const popovers = document.querySelectorAll('a.footnote-ref[data-toggle="popover"]');
for (let popover of popovers) {
  const div = document.createElement('div');
  div.setAttribute('style', 'position: absolute; top: 0, left:0; width:0, height:0, overflow: hidden; visibility: hidden;');
  div.innerHTML = popover.getAttribute('data-content');

  var has_math = div.querySelector("span.math");
  if (has_math) {
    document.body.appendChild(div);
    MathJax.Hub.Queue(["Typeset", MathJax.Hub, div]);
    MathJax.Hub.Queue(function() {
      popover.setAttribute('data-content', div.innerHTML);
      document.body.removeChild(div);
    })
  }
}
</script>
</body>
</html>
